package com.mybatis.test;

import com.mybatis.test.config.AppConfig;
import com.mybatis.test.dao.UserDao;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.*;

/**
 * 描述：Mybatis 的整合启动入口
 *
 * @author lida
 * @time 2019/11/30 11:30
 */
public class MyBatisMainApplicationContext {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();
		ac.register(AppConfig.class);

		ac.refresh();
		UserDao userDao = ac.getBean(UserDao.class);
		List<Map<String, Object>> list = userDao.getUserByName("立达");

		for (Map<String, Object> map : list) {
			System.out.println(map.toString());
			System.out.println(map.get("name"));
			System.out.println(map.get("id"));
		}
	}
}
